package com.example.detail

import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.common.RouterPath
import com.shuyu.gsyvideoplayer.GSYBaseActivityDetail
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
@Route(path = RouterPath.PATH_ACTIVITY_VIDEO)
class VideoPlaverGsyMainActivity : GSYBaseActivityDetail<StandardGSYVideoPlayer>()  {

    @Autowired
    @JvmField
    var playerUrl: String = "http://alvideo.ippzone.com/zyvd/98/90/b753-55fe-11e9-b0d8-00163e0c0248"

    private lateinit var detailPlayer :StandardGSYVideoPlayer

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_video_plaver_gsy_main)

        ARouter.getInstance().inject(this)
        detailPlayer=findViewById(R.id.detail_player)
        detailPlayer.titleTextView.visibility = View.GONE
        detailPlayer.backButton.visibility = View.GONE
        initVideoBuilderMode()

        //允许window 的内容可以上移到刘海屏状态栏
        if (window != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            val lp = window.attributes
            lp.layoutInDisplayCutoutMode =  WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
            window.attributes = lp
        }

        detailPlayer.startPlayLogic()


    }

    override fun getGSYVideoPlayer(): StandardGSYVideoPlayer =detailPlayer

    override fun getGSYVideoOptionBuilder(): GSYVideoOptionBuilder {
        val imageView = ImageView(this)
        return GSYVideoOptionBuilder()
            .setThumbImageView(imageView)
            .setUrl(playerUrl)
            .setCacheWithPlay(true)
            .setVideoTitle("视频Vlog")
            .setIsTouchWiget(true)
            .setRotateViewAuto(false)
            .setLockLand(false)
            .setShowFullAnimation(false)
            .setNeedLockFull(true)
            .setSeekRatio(1f)
    }

    override fun clickForFullScreen() {

    }

    override fun getDetailOrientationRotateAuto(): Boolean =true
}